const stu = {
    name: 'xiejie',
    age: 18,
    stuInfo: {
        No: 1
    },
    sayHello() {
        console.log('Hello');
    }
}

function deepClone(source) {
    let target;
    if (typeof source === 'object') {
        // 数组
        if (Array.isArray(source)) {
            target = [];
            for (let key in source) {
                target[key] = deepClone(source[key]);
            }
            return target;
        } else if (source === null || source instanceof RegExp || source instanceof Date) {
            return source;
        } else {
            target = {};
            for (let key in source) {
                if (source.hasOwnProperty(key)) {
                    target[key] = deepClone(source[key]);
                }
            }
            return target;
        }
        // 对象
    } else {
        return source;
    }
}
const copyStu = deepClone(stu);
console.log('copyStu', copyStu);